import requests
import pandas as pd

def geocodes(key,address,city=None):
    """获取高德api的地理编码信息"""
    key = "eaa6c638561cbb9629a98d39b44f7261"
    url= "https://restapi.amap.com/v3/geocode/geo?parameters"
    params = {
        "key":key,
        "address":address,
        "city":city
    }
    response = requests.get(url,params=params)
    return response.json()['geocodes'][0]['location']

def walking(key,origin,destination):
    url_walking="https://restapi.amap.com/v3/direction/walking?parameters"
    key="eaa6c638561cbb9629a98d39b44f7261"
    params = {
        "key":key,
        "origin":origin,
        "destination":destination
        }
    route=requests.get(url_walking,params=params)
    return pd.json_normalize(route.json()['route']['paths'][0]['steps'])['instruction'].tolist()
# key = "eaa6c638561cbb9629a98d39b44f7261"
# a="广东省广州市中山大学南方学院西学楼8号"
# b="广东省广州市中山大学南方学院西学楼6号"
# A=geocodes(key,a)
# B=geocodes(key,b)
# C=walking(key,A,B)
# print(C)